package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class GrossProfitMarginRatio extends Equation {

	private double gross_profit;
	private double net_sales;

	public GrossProfitMarginRatio(){}

	public GrossProfitMarginRatio(double grossProfit, double netSales){
		this.gross_profit = grossProfit;
		this.net_sales = netSales;
		value = ( gross_profit / net_sales );
	}

	@Override
	public String getEquationName() {
		return EquationNames.GROSS_PROFIT_MARGIN_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.GROSS_PROFIT );
		requiredFields.add( FieldList.NET_SALES );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		gross_profit = values[0];
		net_sales = values[1];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( " + gross_profit +" / " + net_sales +") = " +value;
	}

	@Override
	public String getEquationString() {
		return "( " + FieldList.GROSS_PROFIT +" / " + FieldList.NET_SALES +")";
	}

	@Override
	public void solve() {
		value = ( gross_profit / net_sales );
	}

}
